package facade;

import javax.ejb.EJB;
import javax.ejb.Stateless;

import sessionBeans.AdministradorArticulosVenta;
import sessionBeans.AdministradorClientes;
import sessionBeans.AdministradorVentas;
import dtos.ArticuloVentaDTO;
import dtos.ClienteDTO;
import dtos.FacturaVentaDTO;
import entities.Cliente;
import exceptions.EntityAlreadyExistException;

/**
 * Session Bean implementation class AdministradorFacadeBean
 */
@Stateless
public class AdministradorFacadeBean implements AdministradorFacade {

    @EJB
    private AdministradorArticulosVenta adminArt;
    
    @EJB
    private AdministradorClientes adminCli;
    
    @EJB
    private AdministradorVentas adminVentas;
	
    public AdministradorFacadeBean() {
        // TODO Auto-generated constructor stub
    }

	@Override
	public boolean guardarFactura(FacturaVentaDTO f)
			throws EntityAlreadyExistException {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean guardarCliente(ClienteDTO c)
			throws EntityAlreadyExistException {
		Cliente cli = new Cliente();
		cli.setCodigo(c.getCodigo());
		cli.setCelular(c.getCelular());
		cli.setCodigoPostal(c.getCodigoPostal());
		cli.setDomicilio(c.getDomicilio());
		cli.setLocalidad(c.getLocalidad());
		cli.setNombre(c.getNombre());
		cli.setTelefono(c.getTelefono());
		boolean existe = this.adminCli.grabarCliente(cli);
		return existe;
		
	}

	@Override
	public boolean guardarArticuloVenta(ArticuloVentaDTO a)
			throws EntityAlreadyExistException {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public ClienteDTO buscarCliente(int codigo) {
		Cliente cli = adminCli.buscarCliente(codigo);
		ClienteDTO c = new ClienteDTO();
		c = c.parseDTO(cli);
		return c;
	}

	@Override
	public ClienteDTO buscarCliente(String nombre) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public ClienteDTO buscarClienteDom(String domicilio) {
		// TODO Auto-generated method stub
		return null;
	}

}
